home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
oper_sys
/
emerald
/
emrldsys.lha
/
Language
/
Compiler
/
option.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-08-16
|
2KB
|
91 lines
/*
* @(#)option.c 1.4 9/24/87
*/
#include "types.h"
#include "flags.h"
#include "assert.h"
#include "option.h"
#include "trace.h"
int optioninvokequeue = 1,
optionallocateregisters = 1,
optioncomment = 1,
optionnilspace = 1,
optionlocals = 1,
optionknowct = 1,
optionview = 2,
optioninline = 0,
optiondebugstack = 0,
optioncreateonstack = 1;
typedef struct {
char *name;
int *flag;
} flagTable, *flagTablePtr;
flagTable optionTable [] = {
"invokequeue", &optioninvokequeue,
"allocateregisters", &optionallocateregisters,
"comment", &optioncomment,
"nilspace", &optionnilspace,
"locals", &optionlocals,
"knowct", &optionknowct,
"view", &optionview,
"inline", &optioninline,
"debugstack", &optiondebugstack,
"createonstack", &optioncreateonstack,
NULL, 0
};
extern void toLower();
extern char *find();
parseOptionFlag(f)
register char *f;
{
char *comma, *equals;
register flagTablePtr tp;
int value;
assert(*f == '-'); f++;
assert(*f == 'O'); f++;
toLower(f);
while (f && *f) {
comma = find(f, ',');
if (comma != NULL) *comma = '\0';
equals = find(f, '=');
if (equals == NULL) {
value = 1;
} else {
value = atoi(equals+1);
if (value < 0) value = 1;
*equals = '\0';
}
for (tp = &optionTable[0]; tp->name; tp++) {
if (!strcmp(f, tp->name)) {
*tp->flag = value;
break;
}
}
if (tp->name == NULL) {
fprintf(stdout, "Unknown option name \"%s\"\n", f);
return(0);
}
f = (comma == NULL ? NULL : comma + 1);
}
return(1);
}
void initializeOption()
{
register flagTablePtr tp;
IFTRACE(help, 1) {
fprintf(stdout, "Option\t\tValue\n");
for (tp = &optionTable[0]; tp->name; tp++) {
fprintf(stdout, "\"%s\" -->\t%d\n", tp->name, *tp->flag);
}
}
}